/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ez2find.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

/**
 *
 * @author org.@le
 */

@NamedQuery (name="listAllNicks", query="SELECT c FROM Nick c" )
   
@Entity
public class Nick implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String privacy;
    private String url;
    private String note;
    private String orders;
    private String anons;

    @ManyToOne
    private RegisterUser user;
    
    @OneToMany (mappedBy="handle", cascade=CascadeType.REMOVE)
    private List<Message> messages;
    
    @OneToMany (mappedBy="handle", cascade=CascadeType.REMOVE)
    private List<Topic> topics;
    
    
    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Nick)) {
            return false;
        }
        Nick other = (Nick) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ez2find.model.Nick[id=" + id + "]";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrivacy() {
        return privacy;
    }

    public void setPrivacy(String privacy) {
        this.privacy = privacy;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getOrders() {
        return orders;
    }

    public void setOrders(String orders) {
        this.orders = orders;
    }

    public String getAnons() {
        return anons;
    }

    public void setAnons(String anons) {
        this.anons = anons;
    }

      public RegisterUser getUser() {
          return user;
      }

     public void setUser(RegisterUser user) {
         this.user = user;
     }

    public List<Message> getMessages() {
        if (messages==null){
            messages=new ArrayList<Message>();
        }
        return messages;
    }

    public void setMessages(List<Message> messages) {
        this.messages = messages;
    }

    public List<Topic> getTopics() {
        if (topics==null){
        topics=new ArrayList<Topic>();
        }
        return topics;
    }

    public void setTopics(List<Topic> topics) {
        this.topics = topics;
    }
}
